# _*_ coding: utf-8 _*_
from odoo import models, api, fields
import odoo.addons.decimal_precision as dp


class OLHRExpenseSheetExtend(models.Model):
    _inherit = "hr.expense.sheet"

    state = fields.Selection([('draft', 'New'),
                              ('submit', 'Submit'),
                              ('approve', 'Approved'),
                              ('post', 'Posted'),
                              ('done', 'Paid'),
                              ('cancel', 'Refused')
                              ], string='Status', index=True, readonly=True, track_visibility='onchange', copy=False,
                             default='draft', required=True,
                             help='Expense Report State')
    employee_id = fields.Many2one('hr.employee', string="Employee", required=True, readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1))
    responsible_id = fields.Many2one('res.users', 'Validation By', readonly=True, copy=False, states={'draft': [('readonly', False)]})
    company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.user.company_id)
    currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, states={'draft': [('readonly', False)]}, default=lambda self: self.env.user.company_id.currency_id)

    @api.multi
    def reset_expense_sheets(self):
        return self.write({'state': 'draft'})

    @api.multi
    def submit_expense_sheets(self):
        return self.write({'state': 'submit'})
